var djcx = {
    setBtnStatus:function () {
        var row = $('#grid_djcx').datagrid('getSelected');
    }
}

$(function () {

    //表格初始加载
    $('#grid_djcx').datagrid({
        url:$.webPath() + "/djgl/djcx/djcxList",
        toolbar:"#toolbar_djcx",
        fitColumns:true,
        singleSelect:true,
        pagination:true,
        pageNumber:1,
        fit:true,
        selectOnCheck:false,
        rownumbers:true,
        striped:true,
        showFooter:true,
        columns:[
            [
                {field:'cgdh', title:'采购单号', align:'center', width:107, formatter:cgdCell},
                {field:'cglx_text', title:'采购类型', align:'center', width:61},
                {field:'gys_jc', title:'供应商名称', align:'center', width:96},
                {field:'cgsl', title:'采购重量', align:'right',
                    formatter:function (value) {
                        var sl = formatSlForHtml(value);
                        return sl;
                    }, width:96},
                {field:'cgje', title:'采购金额(元)', align:'right',
                    formatter:function (value) {
                        var sl = formatJeForHtml2(value);
                        return sl;
                    }, width:111},
                {field:'glfyje', title:'物流费用(元)', align:'right',
                    formatter:function (value) {
                        var sl = formatJeForHtml2(value);
                        return sl;
                    }, width:111},
                {field:'dzck_mc', title:'到货仓库', align:'center', width:75},
                {field:'cggs_jc', title:'采购公司', align:'center', width:67},
                {field:'sbgs_jc', title:'申报公司', align:'center', width:63},
                {field:'sbr_xm', title:'申报人', hidden:true},
                {field:'createUser_xm', title:'制单人', hidden:true},
                {field:'yrk', title:'入库状态', width:49, align:'center', formatter:function (value) {
                    if (value == "1")
                        return "已入库";
                    else if (value == "0")
                        return "未入库"
                }},
                {field:'zt_text', title:'状态', align:'center', width:46}
            ]
        ],
        onLoadSuccess:function () {
            djcx.setBtnStatus();
            $(".datagrid-htable .datagrid-cell").css('text-align', 'center');
        },
        onClickRow:function () {
            djcx.setBtnStatus();
        }
    });

    //**********按钮触发事件**********
    //查询按钮
    $("#btn_djcx_search").click(function () {
        djcx_search();
    });

});


//单据查询
function djcx_search() {
    var dhhm = $('#query_dhhm').val() == null ? null : $('#query_dhhm').val();
    var djcxStart = $('#djcxStart').datebox('getValue');
    var djcxEnd = $('#djcxEnd').datebox('getValue');
    $('#grid_djcx').datagrid('load',
        {
            dhhm:dhhm,
            djcxStart:djcxStart,
            djcxEnd:djcxEnd
        }
    );
}




